package tech.aistar.day05.homework;

import java.util.Date;

/**
 * 本类用来演示:
 *
 * @author: success
 * @date: 2022/7/25 9:04 上午
 */
public class HourlyEmployee extends Employee{
    private double hours;//工作的小时数

    private double salaryOfHours;//每个小时的工资

    public HourlyEmployee() {
    }

    public HourlyEmployee(String name, Date birthday, double hours, double salaryOfHours) {
        super(name, birthday);
        this.hours = hours;
        this.salaryOfHours = salaryOfHours;
    }

    /**
     *每月工作超出160小时的部分按照1.5倍工资发放。
     * @param month
     * @return
     */
    @Override
    public double getSalary(int month) {
        double total = hours * salaryOfHours;

        if(hours>160){
            total+=(hours-160)*salaryOfHours*0.5;
        }

        return total + super.getSalary(month);
    }
}
